package com.imooc.springcloudstreamtest.message;

import com.imooc.springcloudstreamtest.pojo.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * 接收消息端
 * @Author: 阿俊哥
 * @Date: 2019/6/15 15:27
 * @Version 1.0
 */
@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class ReciveMessage {

    /**
     * 接收测试的消息
     * @param person
     * @return
     */

    @StreamListener(StreamClient.OUTPT)
    @SendTo(StreamClient.INPUT)
    public String  process(Person person){
        log.info("person:"+person);
        System.out.println("name:"+person.getName()+"  age:"+person.getAge());
        return "我收到了！";
    }

    /**
     *
     * 接收前面返回的回复消息
     * @param message
     */
    @StreamListener(StreamClient.INPUT)
    public void process2(String message)
    {
        System.out.println(message);
    }

}
